<?php

declare(strict_types=1);

namespace App\Controller\WebApi\v1;

use App\Controller\AbstractController;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\Di\Annotation\Inject;
use Service\ConfigService\ConfigService;
use Service\WebLiveService\WebLiveService;
use Hyperf\HttpServer\Annotation\RequestMapping;
use Hyperf\HttpServer\Contract\RequestInterface;

/**
 * 配置中心接口数据
 * @author Luoshumai
 * @Controller(prefix="/webapi/v1/config")
 */
class ConfigController extends AbstractController
{
    /**
     * Inject()
     * @var ConfigService
     */
    protected $configService;

    /**
     * Inject()
     * @var WebLiveService
     */
    protected $webLiveService;


    /**
     * 获取通用配置
     * @RequestMapping(path="index", methods="post")
     */
    public function general()
    {
        return $this->configService->getGeneralConfig();
    }

    /**
     * 显示模块
     * @RequestMapping(path="showModular", methods="post")
     */
    public function showModule(RequestInterface $request)
    {
        return $this->configService->showModule(
            (int)$request->input('cid'),
            (int)$request->input('qid'),
            (int)$request->input('mnid'),
            28327
        );
    }

    /**
     * 客服系统配置
     * @RequestMapping(path="weblive",methods="post")
     */
    public function webLive()
    {
        return $this->webLiveService->getToken();
    }

    /**
     * getCid
     * @RequestMapping(path="getCid",methods="post")
     */
    public function getCid(RequestInterface $request)
    {
        return $this->configService->getCid(
            (string)$request->input('appid'),
            (int)$request->input('mn_sid')
        );
    }

    /**
     * 获取用户协议，隐私协议
     * @RequestMapping(path="getAgreement",methods="post")
     */
    public function getAgreement(RequestInterface $request)
    {
        return $this->configService->getAgreement(
            (int)$request->input('mn_sid'),
            (int)$request->input('cid')
        ); 
    }
}
